package analyse;

import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;

import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeriesCollection;

public class ChartVerwaltung {
	
	public void erstelleXYLineChart() { 	        
        XYDataset xyDataset=new XYSeriesCollection();
        ((XYSeriesCollection) xyDataset).addSeries(null); 
        JFreeChart chart = ChartFactory.createTimeSeriesChart        		
	        ("Preisverlauf",    // Title
	         "Zeit",            // X-Axis label - xAxisLabel
	         "Preis",           // Y-Axis label - yAxisLabel
	         xyDataset,           // Dataset
	         true,              // Show legend
	         true,              //tooltips
	         false              //url
	        ); 
        speichereChart(chart, null); 
    }
 
    public void speichereChart(JFreeChart chart, String file) {    	
        String fileName = file;        
        try {
            /**
             * This utility saves the JFreeChart as a JPEG
             * First Parameter: FileName
             * Second Parameter: Chart To Save
             * Third Parameter: Height Of Picture
             * Fourth Parameter: Width Of Picture
             */
            ChartUtilities.saveChartAsJPEG( new File(fileName), chart, 800, 600 );            
        } catch (IOException e) {        	
        	e.printStackTrace();
            System.err.println("Problem beim Erstellen des Charts!");
        }
     }
 
    private void createCategoryDataset() {
		// neue Daten 
	}
    
    public void erstelleChart() {
    	
    	createCategoryDataset();
    }
    
 	public void speichereChart(){
    	
    }
    
//    public static void main( final String args []) {    	
//        new ChartVerwaltung().createXYLineChart(); 
//        System.out.println("Erstellen Daten bzw. Daten einlesen");        
//    }
 
    
    
    
}
